package situ.autoweter.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import situ.autoweter.entity.RdRead;
import situ.autoweter.service.PyBilldetailService;
import situ.autoweter.entity.PyBilldetail;

import java.beans.PropertyEditor;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * PyBilldetail的路由接口服务
 * 
 * @author 胡文
 *
 */
@Controller
public class PyBilldetailController {

	/** PyBilldetailService服务 */
	@Autowired
	private PyBilldetailService pyBilldetailService;
	
//	/**
//	 * 查询所有PyBilldetail数据的方法
//
//	 */
//	@RequestMapping(value = "queryPyBilldetail", produces = {"application/json;charset=UTF-8"})
//	public String find(PyBilldetail value,Map map) {
//		 List<PyBilldetail> list= pyBilldetailService.find(value);
//         map.put("items",list);
//         return "页面名称自己改";
//	}
//
//	/**
//	 * 通过id查询PyBilldetail数据的方法
//	 *
//	 * @return
//	 */
//	@RequestMapping(value = "queryPyBilldetailById/{id}", produces = {"application/json;charset=UTF-8"})
//	public String findOne(@PathVariable(name="id") Object id,Map map) {
//        PyBilldetail obj=  pyBilldetailService.findOne(id);
//        map.put("PyBilldetail",obj);
//        return "页面名称自己改";
//	}
//
//	/**
//	 * 插入PyBilldetail属性不为空的数据方法
//	 *
//	 * @return
//	 */
//	@RequestMapping(value = "savePyBilldetail", produces = {"application/json;charset=UTF-8"})
//	public String save(PyBilldetail value) {
//		  pyBilldetailService.saveNotNull(value);
//        return "redirect:/queryPyBilldetail";
//	}
//
//	/**
//	 * 更新PyBilldetail属性不为空的数据方法
//	 *
//	 * @return
//	 */
//	@RequestMapping(value = "updatePyBilldetail", produces = {"application/json;charset=UTF-8"})
//	public String update(PyBilldetail value) {
//		  pyBilldetailService.updateNotNullById(value);
//          return "redirect:/queryPyBilldetail";
//	}
//
//	/**
//	 * 通过id删除PyBilldetail数据方法
//	 *
//	 * @return
//	 */
//	@RequestMapping(value = "delPyBilldetailById/{id}", produces = {"application/json;charset=UTF-8"})
//	public String delete(@PathVariable(name="id") Object id) {
//		  pyBilldetailService.deleteById(id);
//          return "redirect:/queryPyBilldetail";
//	}

/*
罗艳分页查询
 */
	@RequestMapping(value = "queryFY", produces = {"application/json;charset=UTF-8"})
	public String queryFY(
			PyBilldetail pyBilldetail,
			@RequestParam(defaultValue = "1",required = false) int startPage,
			@RequestParam(defaultValue = "5",required = false) int pagesize,
			Map map,RdRead rdRead
	){
		PageHelper.startPage(startPage,pagesize);
		List<Map> list=pyBilldetailService.queryFy(pyBilldetail);
		List<RdRead> listRead=pyBilldetailService.queryRdRq(rdRead);
		PageInfo pageInfo=new PageInfo<Map>(list,5);
		map.put("pageInfo", pageInfo);
		map.put("startPage", startPage);
		map.put("pagesize", pagesize);
		map.put("list", list);
		map.put("listRead", listRead);
		return "page/pay_reportDebts.html";
	}
	//时间类型转换器
    @InitBinder
    public void dateconvert(WebDataBinder bind){
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        PropertyEditor n=new CustomDateEditor(format, true);
        bind.registerCustomEditor(Date.class, n);
    }
	/*
	 * 月资金回收情况报表全查
	 * */
//易全查
	@RequestMapping(value = "queryPyBilldetail", produces = {"application/json;charset=UTF-8"})
	public String find(Map map, String ReadDatenb) {
		List<Map> list=pyBilldetailService.find1(ReadDatenb);
		map.put("items", list);
		return "page/pay_reportMonthRecycle";
	}

}
